home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9274 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  52 lines

  1. Path: news.informatik.uni-muenchen.de!usenet
  2. From: Kurt Watzka <watzka@stat.uni-muenchen.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Class problem
  5. Date: Tue, 27 Feb 1996 19:21:34 +0100
  6. Organization: Institut fⁿr Statistik
  7. Message-ID: <31334BAE.6E09@stat.uni-muenchen.de>
  8. NNTP-Posting-Host: pc9.stat.uni-muenchen.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (WinNT; I)
  13.  
  14. Pam Layton wrote:
  15. > Hi.  I'm new at C++ programming.  I am working on a program (that
  16. > is to be complete by 2/28/96).  I have to have one class of name
  17. > information, and one class of address information.  I have a menu
  18. > to choose whether to add, display, remove or exit.  I have most of
  19. > the code written.  My problem:  I use Borland C++ ver. 3.1.  It
  20. > keeps giving me an error saying "Illegal Structure Operation" on
  21. > these two lines:
  22. >                   cin >> addr.zip;
  23. >                   cin >> addr.phone;
  24. > Both of these fields are listed within my address class.  I have it
  25. > listed as:
  26. >                 class addr_data:public name_data
  27. >                 {
  28. >                  public:
  29. >                      char street[25];
  30. >                      char city[15];
  31. >                      char state[3];
  32. >                      int zip[11];
  33. >                      int phone[10];
  34. >                  }addr;
  35. > Can someone please tell me what is wrong with this picture?  I
  36. > appreciate it.
  37.  
  38. You don't have an "istream &operator>>(istream &is, int *)",
  39. and you probably don't want it. Most phone numbers and ZIP codes 
  40. can be stored in an int, and those few that cannot, canot be stored 
  41. in an array of int, either.
  42.  
  43. Think about
  44.  
  45.  a) Changing "zip" and "phone" to int or
  46.  b) Changing them to arrays of char.
  47.  
  48. Kurt
  49.